package com.wd.tech.view.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.wd.tech.R;
import com.wd.tech.bean.BiaotiSerchBean;
import com.wd.tech.bean.ZixunBean;
import com.wd.tech.mvp.base.BaseActivity;
import com.wd.tech.mvp.base.BasePresenter;
import com.wd.tech.mvp.presenter.PresenterImpl;
import com.wd.tech.mvp.util.MyUrl;
import com.wd.tech.view.adapter.SuoAdapter;

import java.util.HashMap;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SousuoActivity extends BaseActivity {


    @BindView(R.id.e1)
    EditText e1;
    @BindView(R.id.sousuo)
    TextView sousuo;
    @BindView(R.id.quxiao)
    TextView quxiao;
    @BindView(R.id.im)
    ImageView im;
    @BindView(R.id.rvv)
    RecyclerView rvv;

    @Override
    protected void startCoding() {

        rvv.setLayoutManager(new LinearLayoutManager(this));


        im.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String s = e1.getText().toString();

                HashMap<String,Object> map1=new HashMap<>();
                map1.put("title",s);
                map1.put("page",1);
                map1.put("count",20);
                mPresenter.startgetInofHava(MyUrl.sousuo, BiaotiSerchBean.class,map1);
            }
        });

        quxiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    protected BasePresenter initPresenter() {
        return new PresenterImpl();
    }

    @Override
    protected void initView() {

    }

    @Override
    protected int Layout() {
        return R.layout.activity_sousuo;
    }

    @Override
    public void onSuccess(Object o) {


        if (o instanceof BiaotiSerchBean){

            SuoAdapter suoAdapter = new SuoAdapter(this, ((BiaotiSerchBean) o).getResult());

            rvv.setAdapter(suoAdapter);
        }
    }

    @Override
    public void onError(String error) {

    }


}
